/*
 * FBCustom
 * jQ script by Alireza Balouch
 */
$(document).ready(function(){  
    var currentID = 0;
    $('.thelink').click(function(){
        $('#innerajax').html('<iframe src="' + $(this).attr('href') + '?m=ajax" frameborder="no" style="border:0px;height:530px;width:99%;overflow:hidden;"  scrolling="no" allowTransparency="true"></iframe>');
        $('#ajaxcontent').fadeIn();
        currentID = parseInt( $(this).find('span').html() );
        $('#piler').show();
        return false;
    });
    
    $('#upload').click(function(){
        $('#innerajax').html('<iframe src="' + $(this).attr('href') + '" frameborder="no" style="border:0px;height:326px;width:99%;overflow:hidden;"  scrolling="no" allowTransparency="true"></iframe>');
            $('#ajaxcontent').fadeIn();
            $('#piler').hide();
        return false;
    });
    
    $('#closebutton').click(function(){
        $('#ajaxcontent').fadeOut();
        $('#piler').hide();
    });
    
    $('#sendknapp').click(function(){
        if( $('#vilkaar').prop('checked') ){
            $('#myform').submit();
        }
        else{
            alert('Du må godkjenne vilkårene for å laste opp bildet');
        }
    });
      $(document).bind('closeme', function() {
        location.href = "https://s2.fbcustom.com/c/demo/";
      });
      
    // if slide view  
    var nrDivs = 0;
    $('.sliders').each(function(i){
        $('#slidepaging').append('<a href="#" rel="' + i + '" class="button">' + ( i + 1 ) + '</a>');
        nrDivs++;
    });

    var sliderWidth = $('.sliders:first').outerWidth();
    $('.sliders:not(' + '.sliders:first' + ') ').hide();
    $('#slidepaging a').live('click' , function(){
        var thisrel = $(this).attr('rel') ;
        var thisSlide = '#slidernr' + eval( parseInt(thisrel) + 1 );
        $('.sliders:not(' + thisSlide + ') ').fadeOut(500);
        $( thisSlide ).fadeIn(500);
        return false;
    });
    
    $('#mleft').live('click',function(){
       if(currentID != 1 ){
           var thisUrl = 'user.php?uid=' + myarr[ currentID - 2 ] + '/' ;
           currentID = eval(parseInt(currentID) - 1);
           $('#innerajax').html('<iframe src="' + thisUrl + '?m=ajax" frameborder="no" style="border:0px;height:530px;width:99%;overflow:hidden;"  scrolling="no" allowTransparency="true"></iframe>');
       } 
       return false; 
    });
    $('#mright').live('click',function(){
        if( currentID != maxID ){
            var thisUrl = 'user.php?uid=' + myarr[ (parseInt(currentID)) ] + '/' ;
            currentID = eval(parseInt(currentID) + 1);
            $('#innerajax').html('<iframe src="' + thisUrl + '?m=ajax" frameborder="no" style="border:0px;height:530px;width:99%;overflow:hidden;"  scrolling="no" allowTransparency="true"></iframe>');
        }
       return false; 
    });
});
/**/